package club.babyf.nativeai.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.http.HttpStatus;

/**
 * BusinessException.
 *
 * @author zhanglei.
 * @date 2025/2/21 15:44.
 * @description 业务异常.
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException {

    private int httpStatus = HttpStatus.OK.value();

    private int code = ErrorCode.BUSINESS_ERROR.getCode();

    public BusinessException() {
        super(ErrorCode.BUSINESS_ERROR.getMsg());
    }

    public BusinessException(String message) {
        super(message);
    }

    public BusinessException(String message, int code) {
        super(message);
        this.code = code;
    }

    public BusinessException(String message, int code, int httpStatus) {
        super(message);
        this.httpStatus = httpStatus;
        this.code = code;
    }

    @Override
    public String toString() {
        return "BusinessException{" +
                "httpStatus=" + httpStatus +
                ", message=" + super.getMessage() +
                ", code=" + code +
                '}';
    }

}
